<template>
    <!-- 图纸目录清单 -->
    <base-breadcrumb>
        <searchData :searchData="searchArr" @search="search"></searchData>
        <a-card>
            <div>
                <a-button
                    class="mb12"
                    v-btnPermission="'tm_032_add_01'"
                    type="primary"
                    icon="plus"
                    @click="handleManage(2)"
                    >新增</a-button
                >
            </div>
            <list-table
                ref="table"
                size="default"
                rowKey="key"
                :columns="columns"
                :request="loadData"
                :alert="true"
                show-size-changer
                show-quick-jumper
                showPagination="auto"
            >
                <template slot="index" slot-scope="text,record, index">
                    {{index+1}}
                </template>
                <template slot="operation" slot-scope="text, record">
                    <MoreButton>
                    <a v-btnPermission="'tm_032_loo_04'" @click="handleManage(0, record)">查看</a>
                    <!-- 编辑 -->
                    <span v-btnPermission="'tm_032_edi_02'">
                        <a @click="handleManage(1, record)">编辑</a>
                    </span>

                    <!-- 删除 -->
                    <span v-if="record.detailDTOS == null" v-btnPermission="'tm_032_del_03'">
                        <a @click="handleRemoveParams({ id: record.id })">删除</a>
                    </span>
                        </MoreButton>
                </template>
            </list-table>
        </a-card>
    </base-breadcrumb>
</template>

<script>
import BasePage from '@/views/basePage' // 基础配置
import { getDrawList, delDrawList } from '@/api/technical/designFM'

import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import SelectProject from '@/components/Select/SelectProject' // 项目
import OrgTreeSelect from '@/components/OrgTreeSelect'

const columns = [
  {
    title: '序号',
    dataIndex: 'index',
    scopedSlots: { customRender: 'index' }
  },
    {
        title: '所属分公司',
        dataIndex: 'branchComName'
    },
    {
        title: '所属项目',
        dataIndex: 'projectName'
    },

    {
        title: '操作',
        dataIndex: 'operation',
        width: '230px',
        scopedSlots: { customRender: 'operation' }
    }
]
const searchArr = [
    // {
    //     name: '所属分公司',
    //     valueKey: 'branchComId',
    //     type: SelectSubCompany
    // },
    {
          name: '所属单位',
          valueKey: 'searchQuery',
          type: OrgTreeSelect,
        },
    // {
    //     name: '所属项目',
    //     keyValue: 'branchComId',
    //     valueKey: 'projectId',
    //     type: SelectProject
    // }
]
import { STable } from '@/components'
export default {
    name: 'a' + Date.now(),
    extends: new BasePage(),
    components: {
        STable
    },
    data() {
        this.columns = columns
        this.searchArr = searchArr
        return {
            queryParam: {},
            removeApi: {
                remove: delDrawList
            }, // api
            loadData: async (parameter) => {
                const requestParameters = Object.assign({}, parameter, { query: this.queryParam })

                return getDrawList(requestParameters).then((res) => {
                    return res
                })
            }
        }
    },
    methods: {
        //搜索
        search(value) {
            value && (this.queryParam = value)
            this.$refs.table.refresh(true)
        },
        // 操作栏
        handleManage(type, record={}) {
            let query = {
                editModel: type,
              projectId: record.projectId
            }
            if (record && record.id) {
                query.id = record.id
            }
            this.$router.push({
                name: 'updateDrawingList',
                query
            })
        }
    }
}
</script>


